package cn.thu.thss.mla.structure;

public class MessageInfo {
	private int messageId;
	private String fromAddress;
	private String toAddress;
	private long sendTimeInterval;
	private long recvTimeInterval;
	private long enqueueTimeInterval;
	private long applyTimeInterval;
	private long sendTimeStart;
	private long sendTimeEnd;
	private long recvTimeStart;
	private long enqueueTimeStart;
	private long applyTimeStart;
	private long applyTimeFinish;
	private boolean isGoodMsgInfo;
	public int getMessageId() {
		return messageId;
	}
	public void setMessageId(int messageId) {
		this.messageId = messageId;
	}
	public String getFromAddress() {
		return fromAddress;
	}
	public void setFromAddress(String fromAddress) {
		this.fromAddress = fromAddress;
	}
	public String getToAddress() {
		return toAddress;
	}
	public void setToAddress(String toAddress) {
		this.toAddress = toAddress;
	}
	public long getSendTimeInterval() {
		return sendTimeInterval;
	}
	
	public long getRecvTimeInterval() {
		return recvTimeInterval;
	}
	
	public long getEnqueueTimeInterval() {
		return enqueueTimeInterval;
	}
	
	public long getApplyTimeInterval() {
		return applyTimeInterval;
	}
	
	public long getSendTimeStart() {
		return sendTimeStart;
	}
	public void setSendTimeStart(long sendTimeStart) {
		this.sendTimeStart = sendTimeStart;
	}
	public long getSendTimeEnd() {
		return sendTimeEnd;
	}
	public void setSendTimeEnd(long sendTimeEnd) {
		this.sendTimeEnd = sendTimeEnd;
	}
	public long getRecvTimeStart() {
		return recvTimeStart;
	}
	public void setRecvTimeStart(long recvTimeStart) {
		this.recvTimeStart = recvTimeStart;
	}
	public long getEnqueueTimeStart() {
		return enqueueTimeStart;
	}
	public void setEnqueueTimeStart(long enqueueTimeStart) {
		this.enqueueTimeStart = enqueueTimeStart;
	}
	public long getApplyTimeStart() {
		return applyTimeStart;
	}
	public void setApplyTimeStart(long applyTimeStart) {
		this.applyTimeStart = applyTimeStart;
	}
	public long getApplyTimeFinish() {
		return applyTimeFinish;
	}
	public void setApplyTimeFinish(long applyTimeFinish) {
		this.applyTimeFinish = applyTimeFinish;
	}
	public boolean getIsGoodMsgInfo() {
		return isGoodMsgInfo;
	}
	public void calculateMetrics() {
		recvTimeInterval = recvTimeStart == 0 ? 0 : (enqueueTimeStart - recvTimeStart);
		sendTimeInterval = sendTimeEnd - sendTimeStart - recvTimeInterval;
		enqueueTimeInterval = applyTimeStart - enqueueTimeStart;
		applyTimeInterval = applyTimeFinish - applyTimeStart;
		isGoodMsgInfo = sendTimeInterval >= 0 && recvTimeInterval >= 0 && enqueueTimeInterval >= 0 && applyTimeInterval >= 0;
	}
	
	@Override
	public String toString() {
		return "MessageInfo [messageId=" + messageId + ", fromAddress="
				+ fromAddress + ", toAddress=" + toAddress
				+ ", sendTimeInterval=" + sendTimeInterval
				+ ", recvTimeInterval=" + recvTimeInterval
				+ ", enqueueTimeInterval=" + enqueueTimeInterval
				+ ", applyTimeInterval=" + applyTimeInterval
				+ ", sendTimeStart=" + sendTimeStart + ", sendTimeEnd="
				+ sendTimeEnd + ", recvTimeStart=" + recvTimeStart
				+ ", enqueueTimeStart=" + enqueueTimeStart
				+ ", applyTimeStart=" + applyTimeStart + ", applyTimeFinish="
				+ applyTimeFinish + "]";
	}
	
}
